// ----------------------------------------------------------------------------
// byte_writer.h
// ----------------------------------------------------------------------------
/*
 Description:
 バイト列を書き込むクラス. 
 */
#pragma once
#include <stddef.h>
#include <fw/base/core/noncopyable.h>
#include <fw/base/core/stdinteger.h>

namespace fw
{
	class ByteWriter : private NonCopyable
	{
	private:
		char*		m_data;
		size_t		m_size;
		size_t		m_offset;
	
	public:
		ByteWriter();
		ByteWriter(char* data, size_t size);
		
		void	SetBuffer(char* data, size_t size);
		char*	GetBuffer() const;
		
		void	Write8	(uint8_t  value);
		void	Write16	(uint16_t value);
		void	Write32	(uint32_t value);
		void	Write64	(uint64_t value);
	
		void	Seek	(size_t pos=0);
		size_t	Tell	() const;
		
		template<typename T> void Write(const T t)
		{
			t->Write(*this); // 対応するデータ構造はWriteメソッドを用意しておくこと.
		}
	}; // class ByteWriter
	
} // namespace fw
